Method: Set#<=>
- Defined in:
- lib/set.rb
#<=>(set) ⇒ Object
Returns 0 if the set are equal, -1 / +1 if the set is a proper subset / superset of the given set, or nil if they both have unique elements.
456 457 458 459 460 461 462 463 464 |
# File 'lib/set.rb', line 456 def <=>(set) return unless set.is_a?(Set) case size <=> set.size when -1 then -1 if proper_subset?(set) when +1 then +1 if proper_superset?(set) else 0 if self.==(set) end end |